import Messages.OSTypeEnum;
/**
 * Simple static class to retrieve OSTypeEnum information.
 * For more detailed OS information use the org.apache.commons.lang.SystemUtils library:
 * http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/SystemUtils.html
 * 
 * @author PjotrC
 */
public class OsDetect {
	
	private static OSTypeEnum m_os = null;
 
	
	public static OSTypeEnum getOS() {
		if(m_os == null) {
			String os = System.getProperty("os.name").toLowerCase();
	
			                             m_os = OSTypeEnum.unsupported;
			if(os.indexOf("win")   >= 0) m_os = OSTypeEnum.Windows;		// Windows
			if(os.indexOf("mac")   >= 0) m_os = OSTypeEnum.Mac;			// Mac
			if(os.indexOf("nux")   >= 0) m_os = OSTypeEnum.Unix;		// Linux
			if(os.indexOf("nix")   >= 0) m_os = OSTypeEnum.Unix;		// Unix
			if(os.indexOf("sunos") >= 0) m_os = OSTypeEnum.Solaris;		// Solaris
		}
		
		return m_os;
	}
	
	public static boolean isWindows() {
		return (getOS() == OSTypeEnum.Windows);
	}

 	public static boolean isMac() {
		return (getOS() == OSTypeEnum.Mac);
	}

 	public static boolean isUnix() {
		return (getOS() == OSTypeEnum.Unix);
	}

 	public static boolean isSolaris() {
		return (getOS() == OSTypeEnum.Solaris);
	}
}